#!/sbin/openrc-run

description="barkery"
runtime_dir=/run/$(id -u barkery)-runtime-dir
pidfile=/run/barkery-weston.pid

depend() {
	need net udev seatd
	keyword -jail -prefix -vserver -docker
}

start() {
	ebegin "Starting barkery"
	
	checkpath -m 0700 -o barkery:barkery -d "$runtime_dir"

	start-stop-daemon --start --user barkery:barkery --background --make-pidfile --pidfile "$pidfile" --env "XDG_RUNTIME_DIR=$runtime_dir" --exec /usr/bin/weston -- -c /etc/barkery/weston.ini

	eend $?
}

stop() {
	ebegin "Stopping barkery"

	start-stop-daemon --stop --user barkery:barkery --pidfile "$pidfile" --exec /usr/bin/weston -- -c /etc/barkery/weston.ini

	eend $?
}
